package com.bw.controller.order;


import com.alibaba.dubbo.config.annotation.Reference;
import com.bw.pojo.order.CategoryReport;
import com.bw.service.order.CategoryReportService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/categoryReport")
public class CategoryReportController{

    @Reference
    private CategoryReportService categoryReportService;

    /*
    * 统计2019-04-15的数据
    *
    * */
    @GetMapping("/yesterday")
    public List<CategoryReport> yesterday(){
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDate parse = LocalDate.parse("2019-04-15", dateTimeFormatter);
        System.out.println("日期参数:"+parse);
        return  categoryReportService.categoryReport(parse);
    }

    @GetMapping("/category1Count")
    public List<Map> category1Count(String date1,String date2){
        return categoryReportService.category1Count(date1,date2);
    }
}
